package com.ag.zlw.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbKnowledgeType;
import com.ag.common.AgException;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;
import com.ag.zlw.dao.TbKnowledgeTypeDAO;
import com.ag.zlw.service.KnowledgeTypeService;

/**
 * 专业知识类别
 * 
 * @author 钟龙伟
 * 
 */

@Service("KnowledgeTypeService")
public class KnowledgeTypeServiceImpl implements KnowledgeTypeService {
	@Resource(name = "ZLWTbKnowledgeTypeDAO")
	private TbKnowledgeTypeDAO tbKnowledgeTypeDAO;

	private String IDs;
	@Resource(name = "iDServiceImpl")
	private IIDService idservice;

	public void save(TbKnowledgeType ktKnowledgeType) throws AgException {
		IDs = (String) idservice.findTablePK(IDUtil.TB_KNOWLEDGE_TYPE);
		ktKnowledgeType.setKtId(IDs);
		tbKnowledgeTypeDAO.save(ktKnowledgeType);
	}

	public void delete(TbKnowledgeType ktKnowledgeType) {
		TbKnowledgeType tbKnowledgeType = tbKnowledgeTypeDAO
				.findById(ktKnowledgeType.getKtId());
		tbKnowledgeType.setA(IDUtil.DELETE);
		tbKnowledgeTypeDAO.attachDirty(tbKnowledgeType);
	}

	public void modify(TbKnowledgeType ktKnowledgeType) {
		tbKnowledgeTypeDAO.attachDirty(ktKnowledgeType);
	}

	public List<TbKnowledgeType> findAll() {
		return tbKnowledgeTypeDAO.findAll();
	}
}
